package com.android.nfctouch.manager;

import android.content.Context;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.baselibrary.util.Util;
import com.android.nfctouch.constants.ApiConstants;
import com.lzy.okgo.model.HttpMethod;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class API_Manager {

    //登录
    public static void login(Context context, String phone, String code, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("code", code);
        bodyParames.put("phone", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //登录
    //unionId =
    //code =
    //openId =
    //nickname = // 昵称
    //avatar =  // 头像
    //gender =  // 性别
    public static void login(Context context, String unionId, String code, String openId, String nickname, String avatar, String gender, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("unionId", unionId);
        bodyParames.put("code", code);
        bodyParames.put("openId", openId);
        bodyParames.put("nickname", nickname);
        bodyParames.put("avatar", avatar);
        bodyParames.put("gender", gender);
        OkHttpManager.okHttpRequest(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack, false);
    }


    //unionId =
    //code =
    //openId =
    //userId =
    public static void check_login(Context context, String unionId, String code, String openId, String userId, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("unionId", unionId);
        bodyParames.put("code", code);
        bodyParames.put("openId", openId);
        bodyParames.put("userId", userId);
        OkHttpManager.okHttpRequest(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack, false);
    }


    //发验证码
    public static void sendcode(Context context, String phone, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.sendcode;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("phone", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //我的-用户信息
    public static void userInfo(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.userInfo;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //获取系统配置
    public static void dict_list(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.dict_list;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }


    //填写邀请码
    public static void bind_activationCode(Context context, String activationCode, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.bind_activationCode;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("activationCode", activationCode);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }


    //上传文件  type: 1-头像，2-背景，3-通用
    public static void common_upload(Context context, File file, int type,OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.common_upload;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("type", type+ "");
        OkHttpManager.okHttpFileUpload(context, url, null, bodyParames, file, callBack);
    }

    //保存用户信息    "avatarUrl": "","backgroundUrl": "","birthday": "","lockFlag": 0,"remark": "","sex": "","username": ""
    public static void user_update(Context context, String key,String value, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.user_update;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put(key, value);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }



}
